home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.639 < prev    next >
Text File  |  1992-02-06  |  2KB  |  31 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;}
  2. \paperw11040
  3. \paperh7620
  4. \margl120
  5. \margr120
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ul0\fs28 \
  8. Q:  How do I set the current selection on a Popup?\
  9. \
  10. A:  In 2.0 Interface Builder has a object on the palette that presents a popup menu of choices.  This is actually a button (when you ask IB for the class of this object,  sure enough, it's a button).  It's a special button whose target is a PopUpList and action causes the popup menu to be displayed.  There is no special message for setting the current selection of this popup,  all you do is set the title to be the choice you want to set your popup to, as you would for an ordinary Button.  So, if you have an outlet for a popup called "popUpButton" you can do this:\
  11. \
  12.     [popUpButton  setTitle:"Item2"];\
  13. \
  14. To get the number of the item currently selected, you have to send the indexOfItem: message to the PopUpList (which is the target of the popup Button).  So, with the example above, you would say:\
  15. \
  16.     num=[[popUpButton  target]  
  17. \pard\tx1240\tx2480\tx3740\tx4980\tx6240\tx7480\tx8720\tx9980\tx11220\tx12480\fc0 indexOfItem:[
  18. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 popUpButton
  19. \pard\tx1240\tx2480\tx3740\tx4980\tx6240\tx7480\tx8720\tx9980\tx11220\tx12480\fc0  title]]
  20. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 ];\
  21. \
  22. \
  23. QA639\
  24.  
  25. \fc0 \
  26.  
  27. \pard\tx520\tx1060\tx1600\tx2120\tx2660\tx3200\tx3720\tx4260\tx4800\tx5320\fc0 Valid for 2.0
  28. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\fc0 \
  29. \
  30.  
  31.